﻿package net.wangit.dev.tree;

import net.wangit.Unit;
import net.wangit.context.ActionContext;
import net.wangit.dev.ConsoleDomainUtil;
import net.wangit.support.UnitInterceptor;
import net.wangit.util.Checker;
import net.wangit.view.tree.TreeProvider;

public class TreePreviewUI implements UnitInterceptor {

	public TreePreviewUI() {
	}

	public String intercept(ActionContext ac, Unit unit) throws Exception {
		String domain = ConsoleDomainUtil.getDomain(ac);
		String treeId = ac.getRequestParameter("treeid");
		if (!Checker.isEmpty(domain) && !Checker.isEmpty(treeId))
			unit.getElement("tree").setObject(
					TreeProvider.getTree(domain, treeId));
		return unit.write(ac);
	}
}
